# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=pandas
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.0.5
pkgrel=1
pkgdesc="Cross-section and time series data analysis toolkit (mingw-w64)"
arch=('any')
url="https://pandas.pydata.org/"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-pytz"
         "${MINGW_PACKAGE_PREFIX}-python-dateutil")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-scipy: needed for miscellaneous statistical functions"
            "${MINGW_PACKAGE_PREFIX}-python-matplotlib: needed for plotting"
            "${MINGW_PACKAGE_PREFIX}-python-numexpr: needed for accelerating certain numerical operations (recommended)"
            "${MINGW_PACKAGE_PREFIX}-python-openpyxl: needed for reading/writing Excel file")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-gcc")
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/pandas-dev/${_realname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('69c5d920a0b2a9838e677f78f4dde506b95ea8e4d30da25859db6469ded84fa8')

prepare() {
  cp -a ${_realname}-${pkgver} ${_realname}-py-${pkgver}
}

build() {
  cd ${srcdir}/${_realname}-py-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py build_ext --inplace

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${_realname}-py-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --skip-build \
    --prefix=${MINGW_PREFIX} --root=${pkgdir} --optimize=1

  install -Dm644 LICENSE \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
